<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function isHui(str) {
            var a = str.length;
            var n = parseInt(a / 2);
            for (var i = 0; i < n; i++) {
                if (str[i] != str[a - 1 - i]) {
                    return false;
                }
            }
            return true;
        }
        console.log(isHui('abba'))
        console.log(isHui('abcd'))
    </script>
</body>

</html>